package com.bckj.fastboot.iot.biz.repository.impl;

import com.bckj.fastboot.core.redis.RedisOps;
import com.bckj.fastboot.iot.common.constant.IotCacheConstants;
import com.bckj.fastboot.iot.common.repository.IotLiveDataRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * IotLiveDataRepositoryImpl
 *
 * @author wfc
 **/
@Repository
public class IotLiveDataRepositoryImpl implements IotLiveDataRepository {

    @Resource
    private RedisOps redisOps;

    @Override
    public void save(String devCode, Map<String, Object> data) {
        redisOps.hmset(IotCacheConstants.IOT_LIVE_DATA_KEY_PREFIX + devCode, data);
    }

    @Override
    public Map<String, Object> get(String devCode) {
        return redisOps.hmget(IotCacheConstants.IOT_LIVE_DATA_KEY_PREFIX + devCode);
    }
}
